<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    div {
      width: 80px;
    }

    input[type=text] {
      width: 50px;
      height: 44px;
      outline: none;
      border: 1px solid #ccc;
      text-align: center;
      border-right: 0;
    }

    input[type=button] {
      height: 24px;
      width: 22px;
      cursor: pointer;
    }

    input {
      float: left;
      border: 1px solid #ccc;

    }
  </style>
</head>

<body>
  <div>
    <input type="text" id="total" value="1" readonly>
    <input type="button" value="+" id="add">
    <input type="button" value="-" id="reduce" disabled>
    <script>
      // 获取元素
      let total = document.querySelector('#total')
      let add = document.querySelector('#add')
      let reduce = document.querySelector('#reduce')

      add.addEventListener('click', function () {
        // 每点击一次 + 按钮 文本框的值 自加1
        total.value++
        // 文本框默认值为1  ++后大于1 则把减号 禁用去掉
        reduce.disabled = false

      })

      reduce.addEventListener('click', function () {
        // 每点击一次 - 按钮 文本框的值 自减1
        total.value--
        // 判断 文本框的值是否 小于或者等于1  成立则禁用 减 按钮
        if (total.value <= 1) {
          reduce.disabled = true
        }
      })
    </script>
  </div>
</body>

</html>